//
// Directory.h
// Usage: VFS directory object
// CreateDate: 2009-05-19
// Author: MaJiuyue
//
#ifndef _DIRECTORY_H_
#define _DIRECTORY_H_

#include <LinkedList.h>
#include <errno.h>
#include "File.h"

class Directory : public File
{
friend class VFS;
private:
	LinkedList<File *> m_Entrys;
	Directory * m_MountPoint;

public:
	Directory(const char *name, u32 inode, size_t length, FileSystem * fs);
	virtual ~Directory();

public:
	/* Add file to this directory */
	int AddEntry(File * entry);
	/* Get file of index */
	File * GetEntry(int index);
	/* Get entrys count of this directory */
	int GetEntryCount();

	/* Mount this dir to target */
	int Mount(Directory * target);
	/* Unmount this dir */
	void Unmount();

public:
	virtual int read(int off, size_t size, addr_t buf);
	virtual int write(int off, size_t size, addr_t buf);
};

#endif

